from pydantic import BaseModel, EmailStr
from typing import Optional
from datetime import datetime
from uuid import UUID  # 添加这行导入

# 基础用户模型
class UserBase(BaseModel):
    email: EmailStr
    nickname: Optional[str] = None

# 创建用户请求
class UserCreate(UserBase):
    password: str
    confirm_password: str

# 用户登录请求
class UserLogin(BaseModel):
    email: EmailStr
    password: str

# 修改密码请求
class PasswordReset(BaseModel):
    email: EmailStr
    old_password: str
    new_password: str
    
# 用户信息响应
class UserProfile(UserBase):
    id: str  # 改为 str
    avatar: Optional[str] = None
    create_time: datetime
    last_login_time: Optional[datetime] = None

    class Config:
        from_attributes = True
# Token响应
class Token(BaseModel):
    access_token: str
    token_type: str = "bearer"
    user: UserProfile

# Token数据
class TokenData(BaseModel):
    user_id: str  # 改为 str
    email: str



# 收藏项
class FavoriteItem(BaseModel):
    id: str  # 改为 str
    node_id: str
    title: str
    type: str
    create_time: datetime

    class Config:
        from_attributes = True

# 浏览历史
class HistoryItem(BaseModel):
    id: str  # 改为 str
    node_id: str
    title: str
    type: str
    view_time: datetime

    class Config:
        from_attributes = True